package com.example.myapplication1.publishFriendCircle;

import android.graphics.Canvas;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

import com.blankj.utilcode.util.ScreenUtils;
import com.blankj.utilcode.util.SizeUtils;


public abstract class BottomDeleteDragListener<T, VH extends RecyclerView.ViewHolder> implements DragListener<T, VH> {
    @Override
    public boolean stateIsInSpecialArea(boolean isInArea, boolean isFingerUp, int position) {
        return false;
    }

    @Override
    public void doBothInAreaAndFingerUp(boolean isInArea, boolean isFingerUp) {
    }

    @Override
    public boolean checkIsInSpecialArea(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder,
                                        float dX, float dY, int actionState, boolean isCurrentlyActive) {
        return SizeUtils.dp2px(150) >= ScreenUtils.getScreenHeight() - getViewYLocationInScreen(viewHolder.itemView);
    }

    @Override
    public void clearView() {
    }

    public static int getViewYLocationInScreen(View v) {
        if (null == v) return 0;
        int[] a = new int[2];
        v.getLocationOnScreen(a);
        return a[1];
    }
}
